//
//  HomeItemTopView.m
//  SSWiFi
//
//  Created by 酷安 @啥也不会啊啊啊啊啊啊  on 2024/1/24.
//

#import "HomeItemTopView.h"

@interface HomeItemTopView()
@property (weak, nonatomic) IBOutlet UIImageView *img_signalView;
@property (weak, nonatomic) IBOutlet UIImageView *img_chargingView;
@property (weak, nonatomic) IBOutlet UIImageView *img_batteryView;

@end

@implementation HomeItemTopView

- (void)setModel:(HomeDataModel *)model{
    _model = model;
    if([model.network_type.lowercaseString containsString:@"service"]){
        model.signalbar = @"-1";
    }
    NSString *img_signal_name = [NSString stringWithFormat:@"signal%@",@(model.signalbar.integerValue)];
    NSLog(@"signal: %@",img_signal_name);
//    self.img_signalView.image = [UIImage imageNamed:img_signal_name];
    self.img_signalView.image = [[UIImage imageNamed:img_signal_name] qmui_imageWithTintColor:[UIColor qd_titleTextColor]];

    
    
    UIImage *powerImg = [UIImage imageNamed:[NSString stringWithFormat:@"power%@",@(model.battery_pers.integerValue)]];
    if(model.battery_pers.integerValue>0){
        powerImg =[powerImg qmui_imageWithTintColor:[UIColor qd_titleTextColor]];
    }
    self.img_batteryView.image = powerImg;
    [self.img_chargingView setHidden:model.battery_charging.integerValue==0];
}

+ (instancetype)defautView{
    HomeItemTopView *view =[[NSBundle mainBundle] loadNibNamed:@"HomeItemTopView" owner:self options:nil].firstObject;
    return view;
    
}
@end
